﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Text;
using Cosmetic.DataAccess;
using Cosmetic.DataEntity;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;


namespace Cosmetic.Logic
{
    public  class liuyanmagers:LogicBase 
    {

        private liuyan m_liuyan = new liuyan();
        /// <summary>
        /// 添加一条留言
        /// </summary>
        /// <param name="anumber">The product want delete</param>

        public void Insert(liuyan aliuyan)
        {
            m_CosmeticDC.liuyan.InsertOnSubmit(aliuyan);
            m_CosmeticDC.SubmitChanges();
        }

        /// <summary>
        /// 删除一条留言
        /// </summary>
        /// <param name="aProduct">The product want delete</param>
        public void Delete(liuyan aliuyan)
        {
            m_CosmeticDC.liuyan.DeleteOnSubmit(aliuyan);
            m_CosmeticDC.SubmitChanges();
        }

        public List<liuyan> GetAll()
        {
            return (from theActivity in m_CosmeticDC.liuyan
                    orderby theActivity.creattime descending
                    select theActivity).ToList();
        }
        public liuyan GetliuyanByid(int id)
        {
            return m_CosmeticDC.liuyan.Single(theComment => theComment.id == id);
        }



        public IEnumerable GetAllliuyan()
        {
            var result = from theFocus in m_CosmeticDC.liuyan 
                         join theProduct in m_CosmeticDC.Users
                         on theFocus.useid  equals theProduct.UserId
                         select new
                         {
                            id=theFocus .id ,
                             //name = theProduct.UserName,
                             creattime = theFocus.creattime,
                             contents = theFocus.contents,
                             fucontents = theFocus.fucontents,
                           
                         };
            return result;
        }
    }
}
